let app = getApp();
Page({
  data: {
    orderInfo: null,
    imageList: [],
    priceVal: 0,
    focusFlag: false,
    orderId: '',
    openid: '',
    comment: ''
  },
  onLoad(options) {
    console.log(options)
    let that = this;
    app.get('DingDanDiZhi', {
      action: 'getDingDanById',
      id: options.id
    }).then((res) => {
      let detail = res.listmingxi, listArr = [];
      for (let i in detail) {
        listArr.push(detail[i].listurl[0].Url)
      }
      that.setData({
        orderInfo: res,
        priceVal: res.YouHuiJinE,
        imageList: listArr,
        orderId: options.id
      });
    });
    wx.getStorage({
      key: 'openid',
      success(res) {
        that.setData({
          openid: res.data
        })
      },
    })
  },
  previewImage(e) {
    var current = e.target.dataset.src
    wx.previewImage({
      current: current,
      urls: this.data.imageList
    });
  },
  priceInput(e) {
    this.setData({
      priceVal: e.detail.value
    });
  },
  amendPrice() {
    let that = this;
    app.get('DingDanDiZhi', {
      action: 'shenhe',
      shifoutongguo: 'fou',
      openid: that.data.openid,
      id: that.data.orderId,
    }).then((res) => {
      wx.navigateBack({
        delta: 1
      });
      app.toast(res.msg);
    });
  },
  submitAmend() {
    let that = this;
    app.get('DingDanDiZhi', {
      action: 'shenhe',
      shifoutongguo:'shi',
      openid: that.data.openid,
      id: that.data.orderId,  
    }).then((res) => {
      if (res.msg === "审核成功！") {
        wx.navigateBack({
          delta: 1
        });
        app.toast(res.msg);
       
      }
    });
  }
})